<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" 
	xmlns:pe="http://primefaces.org/ui/extensions"
	template="/WEB-INF/templates/template.xhtml">
	
<ui:define name="headIncludes">
	<f:event listener="#{compraBean.initializeForm}" type="preRenderView"/>
	
	<style>
/* 		.ui-datatable thead th, .ui-datatable tbody td { */
/* 			padding: 1px 5px; */
/* 		} */
	</style>
</ui:define>
	
	
	<ui:define name="pageName">Cadastrar Compra</ui:define>
	
	<ui:define name="buttons">
		<p:commandButton value="Salvar" style="height:28px;" action="#{compraBean.save}" update="@this, messageFormCompra" icon="ui-icon-disk"/>
		<p:commandButton value="Voltar" style="height:28px;" action="#{compraBean.changeToList}" process="@this" icon="ui-icon-arrowreturnthick-1-w"/>
	</ui:define>
	
	<ui:define name="content">
		<p:panel>
			<div>
				<p:messages id="messageFormCompra" autoUpdate="true"/>
				
				<h:panelGrid columns="6" style="padding:5px;" id="panelInfosIniciais">
					<h:outputText value="Número da nota *" />
					<h:outputText value="Série *" />
					<h:outputText value="Fornecedor *" />
					<h:outputText value="" />
					<h:outputText value="Data de emissão *" />
					<h:outputText value="Data de chegada *" />
					
					<p:inputText style="width:100px;" value="#{compraBean.currentCompra.notaPK.numeroNota}" required="true" requiredMessage="Insira o número da nota." 
						disabled="#{compraBean.currentCompra.itensCompra.size() > 0}" id="inputNumeroNota" maxlength="20">
						<p:ajax event="change" update="@this" listener="#{compraBean.handleInputChange}"/>
						<pe:keyFilter regEx="/[\d]/" />
					</p:inputText>
					<p:inputText style="width:100px;" value="#{compraBean.currentCompra.notaPK.numeroSerie}" required="true" requiredMessage="Insira o número de série"
						disabled="#{compraBean.currentCompra.itensCompra.size() > 0}" id="inputNumeroSerie"  maxlength="20">
						<p:ajax event="change" update="@this" listener="#{compraBean.handleInputChange}"/>
					</p:inputText>
					<p:autoComplete id="inputFornecedor" var="fornecedor" value="#{compraBean.currentCompra.fornecedor}"
						itemLabel="#{fornecedor.nome}" itemValue="#{fornecedor}" size="50" required="true" requiredMessage="Selecione um fornecedor."
						converter="fornecedorConverter" completeMethod="#{compraBean.getFornecedorByQuery}"
						disabled="#{compraBean.currentCompra.itensCompra.size() > 0}">
						<p:ajax event="itemSelect" process="@this inputFornecedor" listener="#{compraBean.handleInputChange}"/>
					</p:autoComplete>
					<p:commandButton icon="ui-icon-search" style="height:24px;" immediate="true" actionListener="#{compraBean.openDialogListFornecedor}"
						disabled="#{compraBean.currentCompra.itensCompra.size() > 0}" id="btSearchFornecedor" title="Selecionar fornecedor"/>					
					<p:calendar value="#{compraBean.currentCompra.emissao}" navigator="true" id="inputDataEmissao"
						readonlyInput="true" showButtonPanel="true" locale="pt_BR" pattern="dd/MM/yyyy" maxdate="#{compraBean.maxDate}"
						disabled="#{(compraBean.currentCompra.notaPK.numeroNota == null) or (compraBean.currentCompra.notaPK.numeroSerie == null) 
							or (compraBean.currentCompra.fornecedor.nome == null) or (compraBean.contasPagar.size() > 0) or (!compraBean.notaLiberada)}">
						<p:ajax event="dateSelect" listener="#{compraBean.handleChegadaDateSelected}"/>
					</p:calendar>
					<p:calendar value="#{compraBean.currentCompra.chegada}" navigator="true" id="inputDataChegada"
						readonlyInput="true" showButtonPanel="true" locale="pt_BR" pattern="dd/MM/yyyy" mindate="#{compraBean.currentCompra.emissao != null ? compraBean.currentCompra.emissao : compraBean.maxDate}"
						disabled="#{(compraBean.currentCompra.notaPK.numeroNota == null) or (compraBean.currentCompra.notaPK.numeroSerie == null) 
							or (compraBean.currentCompra.fornecedor.nome == null) or (compraBean.contasPagar.size() > 0)  or (!compraBean.notaLiberada)}"/>					
				</h:panelGrid>
				
				<h:panelGrid columns="5" style="padding:5px;" id="panelProduto">
					<h:outputText value="Produto"/>
					<h:outputText value="Unidade"/>
					<h:outputText value=""/>
					<h:outputText value="Quantidade"/>
					<h:outputText value="Valor unitário"/>		
									
					<p:autoComplete id="inputProduto" var="produto" value="#{compraBean.itemCompra.produto}"
						itemLabel="#{produto.descricao}" itemValue="#{produto}" size="50"
						converter="produtoConverter" completeMethod="#{compraBean.getProdutoByQuery}"
						disabled="#{(compraBean.currentCompra.notaPK.numeroNota == null) or (compraBean.currentCompra.notaPK.numeroSerie == null) 
							or (compraBean.currentCompra.fornecedor.nome == null) or (compraBean.contasPagar.size() > 0) or (!compraBean.notaLiberada)}"
						onkeypress="if (event.keyCode == 13) { event.preventDefault();  $('#btAdicionarItem').click(); }">
						<p:ajax event="itemSelect" process="@this inputProduto" listener="#{compraBean.handleProdutoSelected}"/>
					</p:autoComplete>
					
					<p:inputText style="width:80px;" value="#{compraBean.itemCompra.produto.unidade}" id="inputUnidadeProduto" disabled="true"/>
					
					<p:commandButton icon="ui-icon-search" style="height:24px;" immediate="true" actionListener="#{compraBean.openDialogListProduto}" id="btSearchProduto"
						disabled="#{(compraBean.currentCompra.notaPK.numeroNota == null) or (compraBean.currentCompra.notaPK.numeroSerie == null) 
							or (compraBean.currentCompra.fornecedor.nome == null) or (compraBean.contasPagar.size() > 0) or (!compraBean.notaLiberada)}" title="Selecionar produto"/>
					
					<p:inputText style="width:80px;" value="#{compraBean.itemCompra.quantidade}" id="inputItemQuantidade"
						disabled="#{(compraBean.currentCompra.notaPK.numeroNota == null) or (compraBean.currentCompra.notaPK.numeroSerie == null) 
							or (compraBean.currentCompra.fornecedor.nome == null) or (compraBean.contasPagar.size() > 0) or (!compraBean.notaLiberada)}"
						maxlength="5"
						onkeypress="if (event.keyCode == 13) { event.preventDefault(); atualizaImpostos(); $('#btAdicionarItem').click();}">
						<p:ajax event="change" update="@this" listener="#{compraBean.handleInputsItemChange}"/>
						<pe:keyFilter regEx="/[\d]/" />
					</p:inputText>
					
					<pe:inputNumber style="width:80px;" value="#{compraBean.itemCompra.valor}" id="inputItemValor" decimalSeparator="," decimalPlaces="2"  thousandSeparator="." maxValue="1000000"
						disabled="#{(compraBean.currentCompra.notaPK.numeroNota == null) or (compraBean.currentCompra.notaPK.numeroSerie == null) 
							or (compraBean.currentCompra.fornecedor.nome == null) or (compraBean.contasPagar.size() > 0)  or (!compraBean.notaLiberada)}" 
						onkeypress="if (event.keyCode == 13) { event.preventDefault(); atualizaImpostos(); $('#btAdicionarItem').click();}">
						<p:ajax event="change" update="@this" listener="#{compraBean.handleInputsItemChange}"/>
					</pe:inputNumber>
				</h:panelGrid>
				
				<p:remoteCommand actionListener="#{compraBean.handleInputsItemChange}" name="atualizaImpostos"/>
				
				<h:panelGrid columns="9" style="padding:5px;" id="panelImpostoItem">
					<h:outputText style="padding-right:10px;" value="BC ICMS"/>
					<h:outputText style="padding-right:10px;" value="% ICMS"/>	
					<h:outputText style="padding-left:10px;padding-right:10px;" value="Valor ICMS"/>		
					<h:outputText style="padding-right:10px;" value="% IPI"/>					
					<h:outputText style="padding-left:10px;padding-right:10px;" value="Valor IPI"/>						
					<h:outputText style="padding-left:10px;padding-right:10px;" value="BC ICMS Subst."/>				
					<h:outputText style="padding-right:10px;" value="% ICMS Subst."/>
					<h:outputText value="Valor ICMS Subst."/>			
					<h:outputText value=""/>
					
					<h:outputText value="#{compraBean.itemCompra.bcIcms}" id="inputItemBcIcms">
						<f:convertNumber pattern="R$ #,###,##0.00" />
					</h:outputText>
					
					<pe:inputNumber style="width:50px;" decimalPlaces="2" decimalSeparator="," thousandSeparator="."  value="#{compraBean.itemCompra.percentualIcms}" 
						id="inputItemPercIcms" maxValue="100"
						disabled="#{(compraBean.currentCompra.notaPK.numeroNota == null) or (compraBean.currentCompra.notaPK.numeroSerie == null) 
							or (compraBean.currentCompra.fornecedor.nome == null) or (compraBean.contasPagar.size() > 0) or (!compraBean.notaLiberada)}"
						onkeypress="if (event.keyCode == 13) { event.preventDefault(); }">
						<p:ajax event="change" update="@this" listener="#{compraBean.handleInputIcmsChange}"/>
					</pe:inputNumber>
					
					<h:outputText style="padding-left:10px;" value="#{compraBean.itemCompra.valorIcms}" id="inputItemValorIcms">
						<f:convertNumber pattern="R$ #,###,##0.00" />
					</h:outputText>
					
					<pe:inputNumber style="width:50px;" decimalPlaces="2" decimalSeparator="," thousandSeparator="." value="#{compraBean.itemCompra.percentualIpi}"
						id="inputItemPercIpi" maxValue="100"
						disabled="#{(compraBean.currentCompra.notaPK.numeroNota == null) or (compraBean.currentCompra.notaPK.numeroSerie == null) 
							or (compraBean.currentCompra.fornecedor.nome == null) or (compraBean.contasPagar.size() > 0) or (!compraBean.notaLiberada)}"
						onkeypress="if (event.keyCode == 13) { event.preventDefault(); }">
						<p:ajax event="change" update="@this" listener="#{compraBean.handleInputIpiChange}"/>
					</pe:inputNumber>
					
					<h:outputText style="padding-left:10px;padding-right:10px;" value="#{compraBean.itemCompra.valorIpi}" id="inputItemValorIpi">
						<f:convertNumber pattern="R$ #,###,##0.00" />
					</h:outputText>
					
					<h:outputText style="padding-left:10px;padding-right:10px;" value="#{compraBean.itemCompra.bcIcmsSubs}" id="inputItemBcIcmsSubs">
						<f:convertNumber pattern="R$ #,###,##0.00" />
					</h:outputText>
					
					<pe:inputNumber style="width:50px;" decimalPlaces="2" decimalSeparator="," thousandSeparator="." value="#{compraBean.itemCompra.percentualIcmsSubs}" 
						id="inputItemPercentualIcmsSubs" maxValue="100"
						disabled="#{(compraBean.currentCompra.notaPK.numeroNota == null) or (compraBean.currentCompra.notaPK.numeroSerie == null) 
							or (compraBean.currentCompra.fornecedor.nome == null) or (compraBean.contasPagar.size() > 0) or (!compraBean.notaLiberada)}"
						onkeypress="if (event.keyCode == 13) { event.preventDefault(); }">
						<p:ajax event="change" update="@this" listener="#{compraBean.handleInputIcmsSubsChange}"/>
					</pe:inputNumber>
					
					<h:outputText value="#{compraBean.itemCompra.valorIcmsSubs}" id="inputItemValorIcmsSubs">
						<f:convertNumber pattern="R$ #,###,##0.00" />
					</h:outputText>
					
					<p:commandButton style="height:24px;" icon="ui-icon-plus" actionListener="#{compraBean.addItemCompra}" id="btAdicionarItem"
						disabled="#{(compraBean.currentCompra.notaPK.numeroNota == null) or (compraBean.currentCompra.notaPK.numeroSerie == null) 
							or (compraBean.currentCompra.fornecedor.nome == null) or (compraBean.contasPagar.size() > 0) or (!compraBean.notaLiberada)}" title="Adicionar item"/>
				
				</h:panelGrid>
				
				<div style="padding-top:10px; padding-bottom:10px;">
					<p:dataTable emptyMessage="Não há registros"
						id="tableItensCompra" value="#{compraBean.currentCompra.itensCompra}"
						var="item">						
						<p:columnGroup type="header">  
				            <p:row>
				            	<p:column rowspan="2" headerText="Cód." width="25"/>			 
								<p:column rowspan="2" headerText="Produto"/> 
								<p:column rowspan="2" headerText="Qtde." width="40"/>
								<p:column rowspan="2" headerText="V. unit." width="50"/>
								<p:column rowspan="2" headerText="V. total" width="50"/>
								<p:column rowspan="2" headerText="BC ICMS" width="40"/>
								<p:column rowspan="2" headerText="V. ICMS" width="40"/>
								<p:column rowspan="2" headerText="V. IPI" width="40"/>
								<p:column rowspan="2" headerText="BC ICMS Subst" width="40"/>
								<p:column rowspan="2" headerText="V. ICMS Subst" width="40"/>
				                <p:column colspan="3" headerText="Alíquotas" /> 
				                <p:column rowspan="2" width="1"/>
				            </p:row>  
				  
				            <p:row>  
				                <p:column headerText="ICMS" width="20"/>  
				                <p:column headerText="IPI" width="20"/>  
				                <p:column headerText="ICMS Subst" width="30"/>  
				            </p:row>  
				        </p:columnGroup>
				        
		            	<p:column style="text-align:center;">  
					    	#{item.produto.id} 
						</p:column>				 
						<p:column>  
					    	#{item.produto.descricao}  
						</p:column> 
						<p:column style="text-align:center;">  
					    	#{item.quantidade}  
						</p:column>
						<p:column style="text-align:center;">  
					    	<h:outputText value="#{item.valor}">
				    			<f:convertNumber pattern="#,###,##0.00" />
				    		</h:outputText> 
						</p:column>
						<p:column style="text-align:center;">  
					    	<h:outputText value="#{item.total}">
				    			<f:convertNumber pattern="#,###,##0.00" />
				    		</h:outputText>		  
						</p:column>
						<p:column style="text-align:center;">  
					    	<h:outputText value="#{item.bcIcms}">
				    			<f:convertNumber pattern="#,###,##0.00" />
				    		</h:outputText>		  
						</p:column>
						<p:column style="text-align:center;">  
					    	<h:outputText value="#{item.valorIcms}">
				    			<f:convertNumber pattern="#,###,##0.00" />
				    		</h:outputText>		  
						</p:column>
						<p:column style="text-align:center;">  
					    	<h:outputText value="#{item.valorIpi}">
				    			<f:convertNumber pattern="#,###,##0.00" />
				    		</h:outputText>		  
						</p:column>
						
						<p:column style="text-align:center;">  
					    	<h:outputText value="#{item.bcIcmsSubs}">
				    			<f:convertNumber pattern="#,###,##0.00" />
				    		</h:outputText>		  
						</p:column>
						
						<p:column style="text-align:center;">  
					    	<h:outputText value="#{item.valorIcms}">
				    			<f:convertNumber pattern="#,###,##0.00" />
				    		</h:outputText>		  
						</p:column>
						
						<p:column style="text-align:center;">  
					    	<h:outputText value="#{item.percentualIcms}">
				    			<f:convertNumber pattern="#,###,##0" />
				    		</h:outputText>		  
						</p:column>
						
						<p:column style="text-align:center;">  
					    	<h:outputText value="#{item.percentualIpi}">
				    			<f:convertNumber pattern="#,###,##0" />
				    		</h:outputText>		  
						</p:column>
						
						<p:column style="text-align:center;">  
					    	<h:outputText value="#{item.percentualIcmsSubs}">
				    			<f:convertNumber pattern="#,###,##0" />
				    		</h:outputText>		  
						</p:column>
				        
						<p:column width="10" style="padding:1px;">  
					    	<p:commandButton icon="ui-icon-trash" actionListener="#{compraBean.removeItemCompra(item)}" style="height:24px;width:23px;" immediate="true" id="btRemoverItem"
					    		disabled="#{(compraBean.currentCompra.notaPK.numeroNota == null) or (compraBean.currentCompra.notaPK.numeroSerie == null) 
					    			or (compraBean.currentCompra.fornecedor.nome == null) or (compraBean.contasPagar.size() > 0) or (!compraBean.notaLiberada)}" title="Remover item"/>
						</p:column>
				  	</p:dataTable>
				</div>
				
				<h:panelGrid columns="5" style="padding:5px;" id="panelImposto1">
					<h:outputText style="padding-right:15px;" value="BC ICMS"/>
					<h:outputText style="padding-right:15px;" value="Valor ICMS"/>
					<h:outputText style="padding-right:15px;" value="BC ICMS Subst."/>
					<h:outputText style="padding-right:15px;" value="Valor ICMS Subst."/>
					<h:outputText style="padding-right:15px;" value="Total dos produtos"/>
									
					<h:outputText style="padding-right:15px;" value="#{compraBean.currentCompra.bcIcms}" id="outputBcIcms">
						<f:convertNumber pattern="R$ #,###,##0.00" />
					</h:outputText>
					
					<h:outputText style="padding-right:15px;" value="#{compraBean.currentCompra.valorIcms}" id="outputValorIcms">
						<f:convertNumber pattern="R$ #,###,##0.00" />
					</h:outputText>
					
					<h:outputText style="padding-right:15px;" value="#{compraBean.currentCompra.bcIcmsSubs}" id="outputBcIcmsSubs">
						<f:convertNumber pattern="R$ #,###,##0.00" />
					</h:outputText>
					
					<h:outputText style="padding-right:15px;" value="#{compraBean.currentCompra.valorIcmsSubs}" id="outputValorIcmsSubs">
						<f:convertNumber pattern="R$ #,###,##0.00" />
					</h:outputText>
					
					<h:outputText style="padding-right:15px;" value="#{compraBean.totalItensNota}" id="totalItens">
						<f:convertNumber pattern="R$ #,###,##0.00" />
					</h:outputText>
				</h:panelGrid>
				
				<h:panelGrid columns="6" style="padding:5px;" id="panelImposto2">
					<h:outputText value="Valor frete"/>
					<h:outputText value="Valor seguro"/>
					<h:outputText value="Desconto (%)"/>
					<h:outputText value="Outras despesas"/>
					<h:outputText style="padding-left:10px;padding-right:10px;" value="Valor IPI"/>
					<h:outputText value="Total da nota"/>
									
					<pe:inputNumber style="width:80px;" decimalPlaces="2" decimalSeparator="," thousandSeparator="." value="#{compraBean.currentCompra.valorFrete}" maxValue="100000"
						disabled="#{(compraBean.currentCompra.notaPK.numeroNota == null) or (compraBean.currentCompra.notaPK.numeroSerie == null)
							or (compraBean.currentCompra.fornecedor.nome == null) or (compraBean.contasPagar.size() > 0) or (!compraBean.notaLiberada)}">
						<p:ajax event="change" listener="#{compraBean.handleInputValoresChange}"/>
					</pe:inputNumber>
					
					<pe:inputNumber style="width:80px;" decimalPlaces="2" decimalSeparator="," thousandSeparator="." value="#{compraBean.currentCompra.valorSeguro}" maxValue="100000"
						disabled="#{(compraBean.currentCompra.notaPK.numeroNota == null) or (compraBean.currentCompra.notaPK.numeroSerie == null) 
							or (compraBean.currentCompra.fornecedor.nome == null) or (compraBean.contasPagar.size() > 0) or (!compraBean.notaLiberada)}">
						<p:ajax event="change" listener="#{compraBean.handleInputValoresChange}"/>
					</pe:inputNumber>
					
					<pe:inputNumber style="width:80px;" decimalPlaces="2" decimalSeparator="," thousandSeparator="." value="#{compraBean.currentCompra.desconto}" maxValue="100"
						disabled="#{(compraBean.currentCompra.notaPK.numeroNota == null) or (compraBean.currentCompra.notaPK.numeroSerie == null) 
							or (compraBean.currentCompra.fornecedor.nome == null) or (compraBean.contasPagar.size() > 0) or (!compraBean.notaLiberada)}">
						<p:ajax event="change" listener="#{compraBean.handleInputValoresChange}"/>
					</pe:inputNumber>
					
					<pe:inputNumber style="width:80px;" decimalPlaces="2" decimalSeparator="," thousandSeparator="." value="#{compraBean.currentCompra.outrasDespesas}" maxValue="100000"
						disabled="#{(compraBean.currentCompra.notaPK.numeroNota == null) or (compraBean.currentCompra.notaPK.numeroSerie == null) 
							or (compraBean.currentCompra.fornecedor.nome == null) or (compraBean.contasPagar.size() > 0) or (!compraBean.notaLiberada)}">
						<p:ajax event="change" listener="#{compraBean.handleInputValoresChange}"/>
					</pe:inputNumber>
					
					<h:outputText style="padding-left:10px;padding-right:10px;" value="#{compraBean.currentCompra.valorIpi}" id="outputValorIpi">
						<f:convertNumber pattern="R$ #,###,##0.00" />
					</h:outputText>
					
					<h:outputText value="#{compraBean.currentCompra.totalNota}" id="totalNota">
						<f:convertNumber pattern="R$ #,###,##0.00" />
					</h:outputText>
				</h:panelGrid>
				
				<h:panelGrid columns="4" style="padding:5px;" id="panelCondicao">
					<h:outputText value="Condição de pagamento *"/>
					<h:outputText value=""/>
					<h:outputText value=""/>
					<h:outputText value=""/>
									
					<p:autoComplete id="inputCondicao" var="condicao" value="#{compraBean.currentCompra.condicaoPagamento}"
						itemLabel="#{condicao.condicaoPagamento}" itemValue="#{condicao}" size="50"
						converter="condicaoPagamentoConverter" completeMethod="#{compraBean.getCondicaoPagamentoByQuery}"
						disabled="#{(compraBean.currentCompra.notaPK.numeroNota == null) or (compraBean.currentCompra.notaPK.numeroSerie == null) 
							or (compraBean.currentCompra.fornecedor.nome == null) or (!compraBean.notaLiberada) or (compraBean.contasPagar.size() > 0)}"/>
					<p:commandButton icon="ui-icon-search" style="height:24px;" immediate="true" actionListener="#{compraBean.openDialogListCondicaoPagamento}" id="btSearchCondicao"
						disabled="#{(compraBean.currentCompra.notaPK.numeroNota == null) or (compraBean.currentCompra.notaPK.numeroSerie == null) 
							or (compraBean.currentCompra.fornecedor.nome == null) or (!compraBean.notaLiberada) or (compraBean.contasPagar.size() > 0)}" title="Selecionar condição de pagamento"/>
					<p:commandButton style="height:24px;" value="Gerar" id="btGerar" actionListener="#{compraBean.gerarContasPagar}" title="Gerar contas a pagar"
						disabled="#{(compraBean.currentCompra.notaPK.numeroNota == null) or (compraBean.currentCompra.notaPK.numeroSerie == null) 
							or (compraBean.currentCompra.fornecedor.nome == null) or (!compraBean.notaLiberada) or (compraBean.currentCompra.itensCompra.size() == 0) or (compraBean.contasPagar.size() > 0)}"/>
					<p:commandButton style="height:24px;" value="Limpar" id="btLimpar" actionListener="#{compraBean.cleanListContasPagar}" title="Limpar contas a pagar"
						disabled="#{(compraBean.currentCompra.notaPK.numeroNota == null) or (compraBean.currentCompra.notaPK.numeroSerie == null) 
							or (compraBean.currentCompra.fornecedor.nome == null) or (compraBean.currentCompra.itensCompra.size() == 0) or (compraBean.contasPagar.size() == 0) or (!compraBean.notaLiberada)}"/>
				</h:panelGrid>
				
				<div style="padding-top:10px; margin-left: 10px;">
					<p:dataTable emptyMessage="Não há registros" style="width:500px;" value="#{compraBean.contasPagar}" 
						var="conta" rowIndexVar="index" id="tableContasPagar">
												
						<p:column headerText="Parcela" style="width:50px; text-align:center;" >  
					    	<h:outputText value="#{index + 1}"/>  
						</p:column>				 
						<p:column headerText="Vencimento" style="width:100px; text-align:center;">  
					    	<h:outputText value="#{conta.dataVencimento}">
								<f:convertDateTime pattern="dd/MM/yyyy"/>
							</h:outputText>  
						</p:column> 
						<p:column headerText="Valor" style="width:100px; text-align:center;">  
					    	<h:outputText value="#{conta.valor}">
				    			<f:convertNumber pattern="R$ #,###,##0.00" />
				    		</h:outputText>   
						</p:column>
				  	</p:dataTable>
				</div>
			</div>
			<h:panelGrid columns="1" style="padding:5px;">
				<h:outputText value="* Campos obrigatórios" />
			</h:panelGrid>
		</p:panel>	
					
	</ui:define>
	<ui:define name="popups">
		<ui:include src="listProduto.xhtml"/>
		<ui:include src="formProduto.xhtml"/>
		<ui:include src="listGrupo.xhtml"/>
		<ui:include src="formGrupo.xhtml"/>
		<ui:include src="listCondicaoPagamento.xhtml"/>
		<ui:include src="formCondicaoPagamento.xhtml"/>
		<ui:include src="listFormaPagamento.xhtml"/>
		<ui:include src="formFormaPagamento.xhtml"/>
		<ui:include src="listFornecedor.xhtml"/>
		<ui:include src="formFornecedor.xhtml"/>
		<ui:include src="listPais.xhtml"/>
		<ui:include src="listEstado.xhtml"/>
		<ui:include src="listCidade.xhtml"/>
		<ui:include src="formPais.xhtml"/>
		<ui:include src="formEstado.xhtml"/>
		<ui:include src="formCidade.xhtml"/>
		
		<p:dialog appendToBody="true" modal="true" closable="false" widgetVar="popupConfirmAddItem"
			width="400" resizable="false" header="Confirmação" height="90">
			<h:form>
				<div style="margin-top: 10px;">
					<h:outputText value="Já existe um item de compra com este produto. Deseja atualizar as informações deste item?"/>
				</div>
				<div align="right" style="margin-top: 15px;">
					<p:commandButton value="Confirmar" actionListener="#{compraBean.confirmAddItem}" oncomplete="popupConfirmAddItem.hide()"/>
					<p:commandButton value="Cancelar" onclick="popupConfirmAddItem.hide()"/>
				</div>		
			</h:form>			
		</p:dialog>
	</ui:define>
</ui:composition>